<template>
  <s-modal
    title="流程状态"
    :visible="visible"
    width="800px"
    :footer="null"
    @cancel="visible = false"
  >
    <div style="height: 400px">
      <s-bpmn-viewer :xml="xml" :active-node="activeNode" />
    </div>
  </s-modal>
</template>

<script>
export default {
  name: 'FlowState',
  data() {
    return {
      confirmLoading: false,
      visible: false,
      xml: null,
      activeNode: []
    }
  },
  methods: {
    open(processDefineId, dataId, workFlowDefineId) {
      this.$loading(true)
      this.$api
        .GET('/workflow/flow/runningNode', { dataId: dataId, workFlowDefineId: workFlowDefineId })
        .then((res2) => {
          this.activeNode = res2.data
          this.$api
            .GET('/workflow/flow/selectBpmnXml', { processDefineId: processDefineId })
            .then((res) => {
              this.$loading(false)
              if (!res.data) {
                this.$message.warn('数据不存在')
              } else {
                this.xml = res.data
                this.visible = true
              }
            })
            .catch(() => {
              this.$loading(false)
            })
        })
        .catch(() => {
          this.$loading(false)
        })
    }
  }
}
</script>

<style lang="less" scoped></style>
